package com.example.demo.zaqizabatest;

import java.sql.*;
import java.util.Properties;

/**
 * ******************************************************
 *
 * @author liugh9
 * @version 1.0
 * @classname JdbcTest
 * @description
 * @date 2022/12/21 17:23
 * <p>
 * ******************************************************
 */
public class JdbcTest {

    public static void main(String[] args) {
        try {
            Class.forName("com.mysql.cj.jdbc.Driver");
            Connection connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "177911");
            Statement statement = connection.createStatement();
            ResultSet resultSet = statement.executeQuery("select * from test");
            ResultSetMetaData metaData = resultSet.getMetaData();
            int columnCount = metaData.getColumnCount();
            for (int i = 1; i <= columnCount; i++) {
                System.out.printf(metaData.getColumnTypeName(i));
                System.out.println(metaData.getColumnClassName(i));
            }
            while (resultSet.next()) {

            }
            System.out.println(metaData.toString());

        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (SQLException e) {
            e.printStackTrace();
        }

    }
}
